Skip to content

feat:Update OpenAPI spec with revised schemas and enhanced event structures#193

Merged
HavenDV merged 1 commit intomainfrom
bot/update-openapi_202507212116
Jul 21, 2025
Merged

feat:Update OpenAPI spec with revised schemas and enhanced event structures#193
HavenDV merged 1 commit intomainfrom
bot/update-openapi_202507212116

Conversation

@HavenDV
Copy link
Copy Markdown
Contributor

@HavenDV HavenDV commented Jul 21, 2025

Summary by CodeRabbit

  • New Features

    • Added detailed usage reporting for image generation, including breakdowns of text and image tokens.
    • Introduced token-level log probability data in reasoning summary events for enhanced transparency.
  • Improvements

    • Clarified and corrected various schema descriptions and event structures.
    • Enhanced event payloads with additional identifiers for better traceability.
    • Updated function calling guide references for accuracy.
  • Removals

    • Removed unused reasoning event types and deprecated style tokens.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 21, 2025

Walkthrough

The OpenAPI specification was updated with new and revised schemas for image generation usage and token log probabilities, enhanced event structures for MCP tool calls, and the removal of certain reasoning event schemas. Descriptions and enumerations were clarified or corrected, and some properties were retyped or made required in various event schemas.

Changes

File(s) Change Summary
src/libs/tryAGI.OpenAI/openapi.yaml - Added schemas: ImageGenInputUsageDetails, ImageGenUsage, ResponseLogProb
- Updated image generation response to use ImageGenUsage
- Enhanced MCP event schemas: added required item_id, output_index; changed delta/arguments to JSON strings
- Removed schemas: ResponseReasoningDeltaEvent, ResponseReasoningDoneEvent and their references
- Extended reasoning summary events with optional logprobs
- Clarified descriptions and fixed enumerations (removed unused style tokens)

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant MCP Tool
    participant ImageGen

    Client->>API: Request image generation
    API->>ImageGen: Generate image with prompt
    ImageGen-->>API: Image + ImageGenUsage (token counts)
    API-->>Client: Response with image and usage details

    Client->>API: Initiate MCP tool call
    API->>MCP Tool: Execute tool (with item_id, output_index)
    MCP Tool-->>API: Result or error (includes item_id, output_index)
    API-->>Client: Event with updated MCP call schema (JSON string arguments/delta)
Loading

Estimated code review effort

4 (~90 minutes)

Poem

A schema hops, a token counts,
New logprobs leap in careful amounts.
MCP tools with IDs clear,
Usage tallies drawing near.
Old reasoning events now take their bow—
The spec’s refreshed, so hop on now!
🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202507212116

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@HavenDV HavenDV enabled auto-merge (squash) July 21, 2025 21:17
@coderabbitai coderabbitai Bot changed the title feat:@coderabbitai feat:Update OpenAPI spec with revised schemas and enhanced event structures Jul 21, 2025
@HavenDV HavenDV merged commit b675ca2 into main Jul 21, 2025
3 of 4 checks passed
@HavenDV HavenDV deleted the bot/update-openapi_202507212116 branch July 21, 2025 21:21
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/libs/tryAGI.OpenAI/openapi.yaml (5)

14901-14914: Validate that token counts can’t go negative

image_tokens / text_tokens are plain integers without any boundary checks. Adding a lower bound of 0 prevents impossible negative counts and helps downstream validation tooling.

       properties:
         image_tokens:
           type: integer
+          minimum: 0
           description: The number of image tokens in the input prompt.
         text_tokens:
           type: integer
+          minimum: 0
           description: The number of text tokens in the input prompt.

15108-15118: Add basic invariants to the usage object

input_tokens, output_tokens, and total_tokens should never be negative and it is typical for total_tokensinput_tokens + output_tokens. While OpenAPI cannot express the cross–field invariant, you can at least disallow negative values with minimum: 0.

        input_tokens:
          type: integer
+         minimum: 0
          description: The number of tokens (images and text) in the input prompt.
...
        output_tokens:
          type: integer
+         minimum: 0
          description: The number of output tokens generated by the model.
...
        total_tokens:
          type: integer
+         minimum: 0
          description: The total number of tokens (images and text) used for the image generation.

17437-17441: Prefer block scalars for multi-line descriptions

Embedding \n escape sequences inside a quoted string decreases readability and is easy to break. YAML block scalars (| or |-) render the same text in a cleaner way and avoid the need to double-escape backslashes.

-      description: "The number of partial images to generate. This parameter is used for\nstreaming responses that return partial images. Value must be between 0 and 3.\nWhen set to 0, the response will be a single image sent in one streaming event.\n\nNote that the final image may be sent before the full number of partial images \nare generated if the full image is generated more quickly.\n"
+      description: |
+        The number of partial images to generate. This parameter is used for
+        streaming responses that return partial images. Value must be between
+        0 and 3. When set to 0, the response will be a single image sent in one
+        streaming event.
+
+        Note that the final image may be sent before the full number of partial
+        images are generated if the full image is generated more quickly.

21442-21447: Mark JSON-encoded strings with a media type

delta is now a raw string that contains JSON. To help clients validate and tooling recognise the content, add the OpenAPI 3.1 contentMediaType hint.

        delta:
           type: string
+          contentMediaType: application/json
           description: "A JSON string containing the partial update to the arguments for the MCP tool call."

21478-21480: Same media-type hint for the finalised arguments field

For consistency with the delta event, mark arguments as JSON-encoded.

        arguments:
           type: string
+          contentMediaType: application/json
           description: "A JSON string containing the finalized arguments for the MCP tool call."
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 644abf8 and a798884.

⛔ Files ignored due to path filters (50)
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI..JsonSerializerContext.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImage.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageEdit.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImage.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageEdit.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ResponseReasoningDeltaEventType.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ResponseReasoningDeltaEventTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ResponseReasoningDoneEventType.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ResponseReasoningDoneEventTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ResponseStreamEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.AuditLog.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.AuditLogProject.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.CodeInterpreterToolCall.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.CodeInterpreterToolCallStatus.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.CreateChatCompletionResponse.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.CreateChatCompletionStreamResponse.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.CreateImageEditRequest.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.CreateImageRequest.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.FunctionObject.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ImageGenInputUsageDetails.Json.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ImageGenInputUsageDetails.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ImageGenUsage.Json.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ImageGenUsage.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ImagesResponse.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ModelResponseProperties.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseLogProb.Json.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseLogProb.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseLogProbTopLogprob.Json.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseLogProbTopLogprob.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPCallArgumentsDeltaEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPCallArgumentsDeltaEventDelta.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPCallArgumentsDoneEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPCallArgumentsDoneEventArguments.Json.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPCallArgumentsDoneEventArguments.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPCallCompletedEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPCallFailedEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPListToolsCompletedEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPListToolsFailedEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseMCPListToolsInProgressEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseReasoningDeltaEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseReasoningDeltaEventDelta.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseReasoningDeltaEventType.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseReasoningDoneEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseReasoningDoneEventType.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseStreamEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseTextDeltaEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ResponseTextDoneEvent.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ServiceTier.g.cs is excluded by !**/generated/**
  • src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.VoiceIdsSharedEnum.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/tryAGI.OpenAI/openapi.yaml (23 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test / Build, test and publish
🔇 Additional comments (2)
src/libs/tryAGI.OpenAI/openapi.yaml (2)

21464-21465: Example payload is syntactically invalid JSON

"delta": "{", is just an opening brace and isn’t valid JSON. Consider using a minimal but complete example (or an obvious JSON fragment such as "{"arg": "value"}").


22260-22264: Confirm cardinality of logprobs

logprobs is an array without minItems/maxItems. If the intention is to mirror the “top-20” behaviour noted in top_logprobs, consider enforcing maxItems: 20 (or documenting why the bound is omitted).

Comment on lines 9057 to 9061
- interpreting
- failed
type: string
description: "The status of the code interpreter tool call.\n"
description: "The status of the code interpreter tool call. Valid values are `in_progress`, `completed`, `incomplete`, `interpreting`, and `failed`.\n"
type:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

incomplete status missing from the enum

The description lists five valid status values but the enum shown in the spec fragment only contains interpreting and failed (the rest may be above the snippet, but it is easy to miss). If incomplete is indeed a valid status, make sure it is explicitly present in the enum array, otherwise the schema and the documentation will diverge.

-            - interpreting
-            - failed
+            - in_progress
+            - completed
+            - incomplete
+            - interpreting
+            - failed

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/libs/tryAGI.OpenAI/openapi.yaml around lines 9057 to 9061, the enum for
status values is missing the 'incomplete' entry, which is listed as a valid
status in the description. Add 'incomplete' explicitly to the enum array to
ensure the schema matches the documented valid status values and avoid
divergence between the schema and documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant